class Solution {
public:
    int maxArea(vector<int>& height) {
        int dest = 0, cur = height.size() - 1;
        int maxv = min(height[dest], height[cur]) * (cur - dest);
        while (dest < cur) {
            if (height[dest] < height[cur]) {
                dest++;
            } else {
                cur--;
            }
            int v = min(height[dest], height[cur]) * (cur - dest);
            if (maxv < v) {
                maxv = v;
            }
        }
        return maxv;
    }
};